<html>
  <head>
    <title>Processing.as Sandbox</title>
    <script type="text/javascript" src="processing.as.js"></script>
    <script type="text/javascript">

var Processing = null;

ProcessingAS.onLoad = function () {
	// swf loaded
	Processing = document.getElementById('processing');
	Processing.start();
};
	
ProcessingAS.onResize = function (w, h) {
	// Processing canvas resized
	Processing.width = w;
	Processing.height = h;
};

function run(code) {
	// sketchy loadImage pre-processing
	var regex = /loadImage\(("[^"]+"|'[^']+')\)/g;
	for (var matches, images = []; (matches = regex.exec(code)) != null; )
		images.push([matches[1].substring(1, matches[1].length - 1), matches[1].substring(1, matches[1].length - 1)]);

	Processing.run(code, images);
}

    </script>
  </head>

  <body style="background: #eee">
    <h1>Processing.as Sandbox</h1>
    
    <p>
      <object data="processing.swf" type="application/x-shockwave-flash" width="0" height="0" id="processing">
        <param name="allowScriptAccess" value="always">
      </object>
    </p>
    
    <p>Paste any Processing script into the textbox below. The script will be parsed and executed in the Processing flash file above.</p>
    
    <textarea rows="30" cols="100" id="code">size(200, 200);
smooth();
background(0);
strokeWeight(10);

for(int i = 0; i &lt; width; i++) {
  float r = random(255);
  float x = random(0, width);
  stroke(r, 100);
  line(i, 0, x, height);
}</textarea><br>
    <input type="submit" value="Run Code" onclick="run(document.getElementById('code').value); return false">
  </body>
</html>